/*
 * IJA2011, Board game "Clovece nezlob se"
 * grp108
 * Tomáš Mičiak,xmicia00
 * Andrej Martinák, xmarti51
 *
 * Created on 6.5.2011, 13:15:14
 */

package src.clovece;

import java.awt.Point;
import java.util.ArrayList;
import src.clovece.game.GameInfo;
import src.clovece.game.Save;

/**
 *  Dialog for saving singleplayer game
 */
public class SaveSinglePlayerGameDialog extends javax.swing.JDialog {
    protected ArrayList<String> al = new ArrayList<String>();
    protected String selected;
    private GameInfo gameInfo = GameInfo.getGameInfoInstance();

    /** Creates new form LoadGameDialog */
    public SaveSinglePlayerGameDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        Point p = parent.getLocation();
        this.setLocation(p.x +300, p.y +150);

    }

     public void showYourself() {
        initComponents();
        if(!this.gameInfo.getHasStarted())
            SaveGameButton.setEnabled(false);
        this.setVisible(true);
    }

    

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        SaveGameButton = new javax.swing.JButton();
        BackButton = new javax.swing.JButton();
        SaveGameLabel = new javax.swing.JLabel();
        TextField = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);

        SaveGameButton.setText("Save");
        SaveGameButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                SaveGameButtonMouseClicked(evt);
            }
        });

        BackButton.setText("Back");
        BackButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BackButtonActionPerformed(evt);
            }
        });

        SaveGameLabel.setText("Save Game");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(53, 53, 53)
                .addComponent(SaveGameButton)
                .addGap(100, 100, 100)
                .addComponent(BackButton)
                .addGap(38, 38, 38))
            .addGroup(layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addComponent(TextField, javax.swing.GroupLayout.DEFAULT_SIZE, 293, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(137, 137, 137)
                .addComponent(SaveGameLabel)
                .addContainerGap(137, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(SaveGameLabel)
                .addGap(24, 24, 24)
                .addComponent(TextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BackButton)
                    .addComponent(SaveGameButton))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BackButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BackButtonActionPerformed
        this.dispose();
    }//GEN-LAST:event_BackButtonActionPerformed

    private void SaveGameButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SaveGameButtonMouseClicked
        Save sav = new Save();
        sav.SaveGame(TextField.getText());
        this.dispose();
    }//GEN-LAST:event_SaveGameButtonMouseClicked


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BackButton;
    private javax.swing.JButton SaveGameButton;
    private javax.swing.JLabel SaveGameLabel;
    private javax.swing.JTextField TextField;
    // End of variables declaration//GEN-END:variables

}
